<template>
  <div>
    <div class="header">
      <router-link to="/home">
        <img src="../../assets/img/home/logo.png" />
      </router-link>
      <div class="userInfo">
        <img class="img" id="top-img" :src="$store.state.userInfo.avatar" />
        <el-popconfirm confirm-button-text="好的" cancel-button-text="不用了"
          icon="el-icon-info" icon-color="red" title="确定要退出登录么？"
          @confirm="quit">
          <el-button slot="reference">{{
            $store.state.userInfo.name
          }}</el-button>
        </el-popconfirm>
        <a href="#" data-toggle="modal" data-target="#settingModel">
          <img src="../../assets/img/home/setting.png" alt="" />
        </a>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: "Head",
  data() {
    return {

    };
  },
  methods: {
    quit() {
      sessionStorage.clear();
      this.$store.dispatch("getUser");
    }
  },
  computed: {
    userInfo() {
      return this.$store.state.userInfo
    }
  },
  mounted() {
    this.$store.dispatch("getUser");
  }
};
</script>

<style lang="scss" scoped>
// 头部
.header {
  width: 1200px;
  margin: 0 auto;
  padding: 0 60px;
  height: 50px;
  display: flex;
  background-color: #fff;
  align-items: center;
  justify-content: space-between;
  .userInfo {
    .img {
      width: 30px;
      height: 30px;
      border-radius: 15px;
      margin-right: 20px;
    }
    display: flex;
    align-items: center;
  }
}
</style>
